-
-
Notifications
You must be signed in to change notification settings - Fork 885
text: Implement double/triple click selection #16946
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
7be1773
to
1a8d716
Compare
All that and tests?! You spoil us! |
I want quadruple click selection!! 😜 |
Unfortunately the test |
core/src/display_object/edit_text.rs
Outdated
/// Maximum duration between two clicks for them to be considered as a multi-click. | ||
/// | ||
/// Derived experimentally to be 250 ms. | ||
const MULTI_CLICK_MAX_DURATION: TimeDelta = TimeDelta::milliseconds(250); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That value is pretty low, usually 500 ms is used. I'm wondering whether in the future we should add an option to increase that as an accessibility setting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to be 500ms for me in FP on Windows
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this affected by the setting mentioned on https://en.m.wikipedia.org/wiki/Double-click#Speed_and_timing ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good shout - yes it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I suspect this is actually not handled by edittext, but a general player event "double click" - which edittext listens to. Triple click is probably custom though.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that's likely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems to be platform-dependent then, because on GNOME it's constant 250 ms irrespective of double click delay setting.
Unfortunately it seems that winit does not support double clicking though. Also, I wouldn't be able to test the behavior of triple clicking as I cannot change the delay 😐
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the delay to 500ms and added a TODO. I will address supporting double clicks at OS level in another PR. It should be easy to implement on the web, but on desktop I'm afraid we will need to add a setting until it's implemented in winit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind, I implemented a rough framework for double clicks, so that the click index may be supplied in player events, and when it's not, it's calculated.
Currently it's not supplied and TODOs are added both in desktop and web (tried js_event.detail
but it doesn't work OOTB).
2c0eb7e
to
d82e9b1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
This patch implements selecting words by double-clicking and selecting lines by triple-clicking. It also includes support for selecting words and lines while dragging.
This test verifies the behavior of selecting text using mouse. It takes into account normal, word, and line selection. Example use cases covered by this test: 1. selecting characters, 2. selecting words by double-clicking, 3. selecting multiple words by double-clicking and dragging, 4. selecting lines by triple-clicking, 5. selecting multiple lines by triple-clicking and dragging, 6. double-clicking at word boundaries, 7. double-clicking between spaces, 8. changing the underlying text while clicking and dragging, 9. trying to select while the text field is not selectable.
d82e9b1
to
b86d437
Compare
Fixes #14996, progresses #1891.
This PR implements selecting words by double-clicking and selecting lines by triple-clicking. It also includes support for selecting words and lines while dragging.
A test is added to verify this behavior. Example use cases covered by this test: